package keke;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main120302 {
	public static void main(String[] args) {
		BufferedReader br = null;
		String src="D:/EncodeTest.txt";
		try {
			String dst="D:/EncodeTest1.txt";
			convertGBK2UTF8(src,dst);
			br = new BufferedReader(new FileReader(dst));
			String line = null;
			while((line=br.readLine())!=null)
				System.out.println(line);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally{
			if (br!=null){
				try {
					br.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
}
	static void convertGBK2UTF8(String src, String dst) throws Exception{//201521123006
		InputStreamReader inputstreamreader = new InputStreamReader(new FileInputStream(src),"UTF-8");
		OutputStreamWriter outputstreamwriter=new OutputStreamWriter(new FileOutputStream(dst));
		BufferedReader bufferedreader=new BufferedReader(inputstreamreader);
		String line = null;
		while((line=bufferedreader.readLine())!=null){
			outputstreamwriter.write(line+"\n");
		}
		bufferedreader.close();
		outputstreamwriter.close();
	}
}

